package com.ofek.eventos.db.datatypes;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;

import com.ofek.eventos.db.ContextDatabase;

public abstract class ContextDefiner implements Serializable {
	public ArrayList<PageDefiner> pages = new  ArrayList<PageDefiner>();
	public boolean add(final PageDefiner object) {
		return pages.add(object);
	}
	public void add(final int index, final PageDefiner object) {
		pages.add(index, object);
		ContextDatabase.getInstance().sync();
	}
	public boolean addAll(final Collection<? extends PageDefiner> collection) {
		final boolean addAll = pages.addAll(collection);
		ContextDatabase.getInstance().sync();
		return addAll;
	}
	public boolean addAll(final int index,
			final Collection<? extends PageDefiner> collection) {
		final boolean addAll = pages.addAll(index,collection);
		ContextDatabase.getInstance().sync();
		return addAll;
	}
	public void clear() {
		pages.clear();
		ContextDatabase.getInstance().sync();
	}
	public boolean removeAll(final Collection<?> collection) {
		final boolean removeAll = pages.removeAll(collection);
		ContextDatabase.getInstance().sync();

		return removeAll;
	}
	public PageDefiner get(final int index) {
		return pages.get(index);
	}
	public  ArrayList<PageDefiner> getAll() {
		return pages;
	}
	public int indexOf(final Object object) {
		return pages.indexOf(object);
	}
	public PageDefiner remove(final int index) {
		final PageDefiner remove = pages.remove(index);
		ContextDatabase.getInstance().sync();

		return remove;
	}
	@Override
	public String toString() {
		return getName();
	}
	public boolean remove(final Object object) {
		final boolean removeAll = pages.remove(object);
		ContextDatabase.getInstance().sync();
		return removeAll;
	}
	public PageDefiner set(final int index, final PageDefiner object) {
		final PageDefiner set = pages.set(index, object);
		ContextDatabase.getInstance().sync();
		return set;
	}
	public abstract String getName();
}
